package com.itheima.job1;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class TestStudent {
    public static void main(String[] args) {
        //反射获取student的Class对象
        Class<Student> clz = Student.class;

        try {
            //获取共有全参构造方法
            Constructor<Student> constructor = clz.getConstructor(String.class, int.class);
            //调用公有、全参构造方法传入柳岩，17岁两个参数
            Student student = constructor.newInstance("柳岩", 17);
            Method show = clz.getMethod("show");
             show.invoke(student);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
